package com.ruoyi.web.controller.vantController.orderController;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.zhuangxiumain.orderformMain.OrderShoppingCart;
import com.ruoyi.system.domain.zhuangxiumain.vo.ShoppingOrderVo;
import com.ruoyi.system.domain.zhuangxiumain.vo.ShoppingPaymentVo;
import com.ruoyi.system.service.vantservice.orderservice.ApiOrderShoppingCartService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by 惠普 on 2021/1/11 14:57
 */
@RestController
@RequestMapping("/api/shoppingCart")
public class ApiOrderShoppingCartController {
    @Resource
    private ApiOrderShoppingCartService apiOrderShoppingCartService;

    /**
     * 添加购物车信息
     * @param orderShoppingCart
     * @return
     */
    @PostMapping("/addOrderShoppingCart")
    public int addOrderShoppingCart(@RequestBody OrderShoppingCart orderShoppingCart){
        return apiOrderShoppingCartService.addOrderShoppingCart(orderShoppingCart);
    }

    /**
     * 查询购物车列表
     * @return
     */
    @PostMapping("/selectOrderShoppingCart")
    public AjaxResult selectOrderShoppingCart(){
        return AjaxResult.success(apiOrderShoppingCartService.selectOrderShoppingCart());
    }

    /**
     * 购物车提交订单
     * @return
     */
    @PostMapping("/addOrder")
    public AjaxResult addOrder(@RequestBody ShoppingOrderVo shoppingOrderVo){
        return AjaxResult.success(apiOrderShoppingCartService.addOrder(shoppingOrderVo));
    }

    /**
     * 购物车线下支付
     * @return
     */
    @PostMapping("/shoppingPayment")
    public AjaxResult shoppingPayment(@RequestBody ShoppingPaymentVo shoppingPaymentVo){
        return AjaxResult.success(apiOrderShoppingCartService.shoppingPayment(shoppingPaymentVo));
    }


    /**
     * 购物车微信
     * @return
     */
    @PostMapping("/shoppingPaymentWx")
    public AjaxResult shoppingPaymentWx(@RequestBody ShoppingPaymentVo shoppingPaymentVo){
        return AjaxResult.success(apiOrderShoppingCartService.shoppingPaymentWx(shoppingPaymentVo));
    }
}
